import { cartList } from "@/api/cart";
import { defineStore } from "pinia";

const useCartInfo = defineStore('cart', {
    state: () => {
        return {
            count: 0,
            list: [],
        }
    },
    actions: {
        // 调用接口获取购物车信息
        async getCartInfo() {
            let res = await cartList({
                page: 1,
                limit: 100
            })
            this.count = res.data.count
            this.list = res.data.list || []
        }
    }
})

export default useCartInfo